﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Project
{
    public partial class FXxiu : Form
    {
        public int id;
        public FXxiu()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            xiu();
        }
        public void xiu() 
        {
            string name = this.textBox3.Text;
            string count = this.textBox2.Text;
            int s = Convert.ToInt32(count);
            string money = this.textBox4.Text;
            decimal b = Convert.ToDecimal(money);
            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("请填写完整");
            }
            string sql =string.Format("update room set RoomName='{0}',RoomWie={1},RoomMoney={2} where RoomId={3}",name,count,money,id);
            int result = FrmHotel.DBHelper.ExecuteUpdate(sql);
            if (result > 0)
            {
                MessageBox.Show("修改成功");

            }
            else
            {
                MessageBox.Show("修改失败");
            }
        }

        private void FXxiu_Load(object sender, EventArgs e)
        {
            s();
        
        }
        public void s() 
        {
            string sql = "select * from room where RoomId= " + id;
            SqlDataReader reader = FrmHotel.DBHelper.SelectMore(sql);
            if(reader.Read())
            {
                this.textBox3.Text = reader["RoomName"].ToString();
                this.textBox2.Text = reader["RoomWie"].ToString();
                this.textBox4.Text = reader["RoomMoney"].ToString();

            }
            reader.Close();
            
        }
  
    }
}
